package com.cea.papyrus.core.preference;

import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.RGB;


public class CommonPreferenceConstants {

    /**
     * The Constant P_COMMENT_BACKGROUNDCOLOR.
     */
    public static final String P_COMMENT_BACKGROUNDCOLOR = "ClassDiagramPreferenceConstants.Comment.backGroundColor";
    /**
     * The Constant P_COMMENT_BORDERCOLOR.
     */
    public static final String P_COMMENT_BORDERCOLOR = "ClassDiagramPreferenceConstants.Comment.borderColor";
    /**
     * The Constant P_COMMENT_FONTCOLOR.
     */
    public static final String P_COMMENT_FONTCOLOR = "ClassDiagramPreferenceConstants.Comment.fontColor";
    /**
     * The Constant P_COMMENT_FONT.
     */
    public static final String P_COMMENT_FONT = "ClassDiagramPreferenceConstants.Comment.font";
    /** Constant for constraint display (constraint name) */
    public static final String P_CONSTRAINT_DISPLAY_NAME = "ClassDiagramPreferenceConstants.Constraint.display.Name";
    /** Constant for constraint display (constraint body) */
    public static final String P_CONSTRAINT_DISPLAY_BODY = "ClassDiagramPreferenceConstants.Constraint.display.Body";
    /**
     * The Constant P_CONSTRAINT_BACKGROUNDCOLOR.
     */
    public static final String P_CONSTRAINT_BACKGROUNDCOLOR = "ClassDiagramPreferenceConstants.Constraint.backGroundColor";
    /**
     * The Constant P_CONSTRAINT_BORDERCOLOR.
     */
    public static final String P_CONSTRAINT_BORDERCOLOR = "ClassDiagramPreferenceConstants.Constraint.borderColor";
    /**
     * The Constant P_CONSTRAINT_FONTCOLOR.
     */
    public static final String P_CONSTRAINT_FONTCOLOR = "ClassDiagramPreferenceConstants.Constraint.fontColor";
    /**
     * The Constant P_CONSTRAINT_FONT.
     */
    public static final String P_CONSTRAINT_FONT = "ClassDiagramPreferenceConstants.Constraint.font";

    /**
     * Gets the preference comment background color.
     * 
     * @param store the store
     * 
     * @return the preference comment background color
     */
    public static RGB getPreferenceCommentBackgroundColor(IPreferenceStore store) {
    	return PreferenceConverter.getColor(store, P_COMMENT_BACKGROUNDCOLOR);
    }

    /**
     * Gets the preference comment border color.
     * 
     * @param store the store
     * 
     * @return the preference comment border color
     */
    public static RGB getPreferenceCommentBorderColor(IPreferenceStore store) {
    	return PreferenceConverter.getColor(store, P_COMMENT_BORDERCOLOR);
    }

    /**
     * Gets the preference comment font color.
     * 
     * @param store the store
     * 
     * @return the preference comment font color
     */
    public static RGB getPreferenceCommentFontColor(IPreferenceStore store) {
    	return PreferenceConverter.getColor(store, P_COMMENT_FONTCOLOR);
    }

    /**
     * Gets the preference comment font.
     * 
     * @param store the store
     * 
     * @return the preference comment font
     */
    public static FontData[] getPreferenceCommentFont(IPreferenceStore store) {
    	return PreferenceConverter.getFontDataArray(store, P_COMMENT_FONT);
    }

    /**
     * Gets the preference for appearance (display Name in Constraint figures).
     * @param store the store
     * @return <code>true</code> if the name must be displayed
     */
    public static boolean getPreferenceConstraintNameAppearance(IPreferenceStore store) {
    	return store.getBoolean(P_CONSTRAINT_DISPLAY_NAME);
    }

    /**
     * Gets the preference for appearance (display Body in Constraint figures).
     * @param store the store
     * @return <code>true</code> if the body must be displayed
     */
    public static boolean getPreferenceConstraintBodyAppearance(IPreferenceStore store) {
    	return store.getBoolean(P_CONSTRAINT_DISPLAY_BODY);
    }

    /**
     * Gets the preference constraint background color.
     * 
     * @param store the store
     * 
     * @return the preference constraint background color
     */
    public static RGB getPreferenceConstraintBackgroundColor(IPreferenceStore store) {
    	return PreferenceConverter.getColor(store, P_CONSTRAINT_BACKGROUNDCOLOR);
    }

    /**
     * Gets the preference constraint border color.
     * 
     * @param store the store
     * 
     * @return the preference constraint border color
     */
    public static RGB getPreferenceConstraintBorderColor(IPreferenceStore store) {
    	return PreferenceConverter.getColor(store, P_CONSTRAINT_BORDERCOLOR);
    }

    /**
     * Gets the preference constraint font color.
     * 
     * @param store the store
     * 
     * @return the preference constraint font color
     */
    public static RGB getPreferenceConstraintFontColor(IPreferenceStore store) {
    	return PreferenceConverter.getColor(store, P_CONSTRAINT_FONTCOLOR);
    }

    /**
     * Gets the preference constraint font.
     * 
     * @param store the store
     * 
     * @return the preference constraint font
     */
    public static FontData[] getPreferenceConstraintFont(IPreferenceStore store) {
    	return PreferenceConverter.getFontDataArray(store, P_CONSTRAINT_FONT);
    }

    public CommonPreferenceConstants() {
        super();
    }
    
    /**
     * Sets the default preferences.
     * 
     * @param store the store
     */
    public static void setDefaultPreferences(IPreferenceStore store) {
        
        // Comment
        PreferenceConverter.setDefault(store, P_COMMENT_BACKGROUNDCOLOR, PreferenceConstants.getPapyrusColorBlue());
        PreferenceConverter.setDefault(store, P_COMMENT_BORDERCOLOR, PreferenceConstants.getPapyrusColorBrown());
        PreferenceConverter.setDefault(store, P_COMMENT_FONTCOLOR, PreferenceConstants.getPapyrusColorBlack());
        PreferenceConverter.setDefault(store, P_COMMENT_FONT, new FontData("Arial", 10, SWT.BOLD));
        
        // Constraint
        store.setDefault(P_CONSTRAINT_DISPLAY_BODY, true);
        store.setDefault(P_CONSTRAINT_DISPLAY_NAME, false);
        PreferenceConverter.setDefault(store, P_CONSTRAINT_BACKGROUNDCOLOR, PreferenceConstants.getPapyrusColorBlue());
        PreferenceConverter.setDefault(store, P_CONSTRAINT_BORDERCOLOR, PreferenceConstants.getPapyrusColorBrown());
        PreferenceConverter.setDefault(store, P_CONSTRAINT_FONTCOLOR, PreferenceConstants.getPapyrusColorBlack());
        PreferenceConverter.setDefault(store, P_CONSTRAINT_FONT, new FontData("Arial", 10, SWT.BOLD));
        
    }    

}